// import { DECREMENT, INCREMENT } from "../const/counter.const";
import { handleActions as createReducer } from 'redux-actions';
import { decrement, increment } from "../actions/countActions";

const initialState = {
  count: 0
}

// function reducer(state = initialState, action) {
//   switch (action.type) {
//     case INCREMENT:
//       return { count: state.count + action.payload };
//     case DECREMENT:
//       return { count: state.count - action.payload };
//     default:
//       return state;
//   }
// }

// function handleIncrement(state, action) {
//   return { count: state.count + action.payload };
// }

const reducer = createReducer({
  [increment]: (state, action) => ({ count: state.count + action.payload }),
  [decrement]: (state, action) => ({ count: state.count - action.payload }),
}, initialState);

export default reducer;